package org.example;


import org.example.mvc.InputStreamWrapperFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.EnableScheduling;


/**
 * @author 22449
 */
@SpringBootApplication
@EnableDiscoveryClient
@ServletComponentScan
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class);
    }


    @Bean
    @Order(1) // Spring Boot 会按照order值的大小，从小到大的顺序来依次过滤。
    public FilterRegistrationBean inputStreamWrapperFilterRegistration() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new InputStreamWrapperFilter());
        registrationBean.setOrder(1);
        registrationBean.setName("inputStreamWrapperFilter");
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }

}
